#!/usr/bin/env python
import csv
import random

inter = csv.reader(open('total_interaction.dat'))

proteins = set()
interactions = dict() 
for i in inter:
    proteins.add(i[0])
    print i[0]
    if interactions.has_key(i[0]):
        interactions[i[0]].append(i)
    else:
        interactions[i[0]] = [i]

for p in proteins:
    group = random.choice(range(10))
    fname = 'test_group'+str(group)+'.pdat'
    with open(fname, 'ab') as f:
        writer = csv.writer(f)
        for i in interactions[p]:
            writer.writerow(i)
